home *** CD-ROM | disk | FTP | other *** search
INI File | 2001-09-10 | 3.0 KB | 95 lines |
- [Name]
- DayOfWeek v1.0 - Provides properties for day of week.
- By Matthew Peterson, matthew@pinoko.berkeley.edu
-
- [Description]
- 2-19-2000
- This behavior has one custom event used to update two Global Variables:
-
- UpDateWeekDay: Updates the following two Global Variables:
- 1) LocalWeekDay: the day of the week (Sunday thru Saturday)
- in the local time zone
-
- 2) GMTWeekDay: the day of the week (Sunday thru Saturday)
- in the GMT time zone
-
- 1 = Sunday, 2 = Monday.... 7 = Saturday
- (a value of 0 means the variable hasn't been evaluated yet. This
- can happen if you have something)
-
- To use this behavior, simply place it on a sprite, and execute the UpDateWeekDay
- event (only needs to be called once during the course of the movie).
- The above global variables will be made available to all sprites in the sprite track.
-
- Currently Quicktime offers properties for local and GMT date and time
- but lacks a property to know what day of the week it is. This is often
- useful for wired movies that want to show something different on
- one day, than what is shown during the rest of the week.
-
- EXAMPLE: (Set the image index of sprite 2 to 19 if today is Monday)
-
- GlobalVars localweekday GMTweekday
-
- spriteofid(1).executeevent($UpdateWeekDay) //really only needs to be called once in the movie.
- //This assumes that this behavior is in spriteofid(1).
- IF(localweekday = 2) //today is monday
- SpriteOfID(2).SetImageIndexTo(19)
- ENDIF
-
- Revision History:
- 3-2-2000 -- Added missing lines that caused the wrong day after the leap year.
-
- [Parameters]
-
- [200008 UpdateWeekDay]
- GlobalVars localweekday GMTweekday MP_thismonth MP_thisyear MP_thisday MP_Tempmonthtoadd[12] MP_janstart
- //Calculates what day of the week it is. 1 = Sunday 2 = Monday... and 7 = Saturday
- //Returns two variable localweekday and GMTweekday.
- //If these values = 0 then this function hasn't been executed yet.
- //By Matthew Peterson.
-
-
- MP_Tempmonthtoadd[0]=0
- MP_Tempmonthtoadd[1]=3
- MP_Tempmonthtoadd[2]=3
- MP_Tempmonthtoadd[3]=6
- MP_Tempmonthtoadd[4]=1
- MP_Tempmonthtoadd[5]=4
- MP_Tempmonthtoadd[6]=6
- MP_Tempmonthtoadd[7]=2
- MP_Tempmonthtoadd[8]=5
- MP_Tempmonthtoadd[9]=0
- MP_Tempmonthtoadd[10]=3
- MP_Tempmonthtoadd[11]=5
-
- MP_thisday = LocalDay
- MP_thisyear = LocalYear - 2000
- MP_thismonth = LocalMonth
-
- IF(MP_thisyear = 0)
- MP_janstart = 6
- ELSE
- MP_janstart = 7 + MP_thisyear + (MP_thisyear - 1) DIV 4
- ENDIF
- IF(MP_thismonth > 2)
- MP_janstart = MP_janstart + ((MP_thisyear REM 4) = 0)
- ENDIF
-
- localweekday = ((MP_janstart + MP_Tempmonthtoadd[MP_thismonth - 1] + MP_thisday - 1) REM 7) + 1
-
- //Calculate again for GMT because we might fall on the edge of a month, and it is just
- //as fast to recalculate as it is to account for possible month crossing.
- MP_thisday = GMTDay
- MP_thisyear = GMTYear - 2000
- MP_thismonth = GMTMonth
-
- IF(MP_thisyear = 0)
- MP_janstart = 6
- ELSE
- MP_janstart = 7 + MP_thisyear + (MP_thisyear - 1) DIV 4
- ENDIF
- IF(MP_thismonth > 2)
- MP_janstart = MP_janstart + ((MP_thisyear REM 4) = 0)
- ENDIF
- GMTweekday = ((MP_janstart + MP_Tempmonthtoadd[MP_thismonth - 1]+MP_thisday - 1) REM 7) + 1
-